<style>
    .show_tb{width: 80%;}
    .show_tb>thead>tr>th, .show_tb>tbody>tr>th, .show_tb>tfoot>tr>th, .show_tb>thead>tr>td, .show_tb>tbody>tr>td, .show_tb>tfoot>tr>td{border: 1px solid #f4f4f4;}
    .show_tb tr td:nth-child(odd){ text-align: right;}
    .show_tb .img_td{text-align: center !important;}
    .show_tb .img_div img{width: 100px; height: 100px; }
    .show_tb .ewm{width: 120px; height: 120px; }
    .show_tb span{padding: 5px 10px; display: block;}
    .show_tb .department{width:50%;margin-left: 25%; color: #fff; background-color: rgba(240, 72, 68, 1); border-radius: 15px;}
    .m_tab{margin-bottom: 10px;}
    .m_tab a{color:#000;}
    .m_tab .tb{display: inline-block;background-color: #fff; padding: 5px 10px;cursor:pointer; margin-right: 5px;}
    .m_tab .tb:hover{color:rgba(26, 188, 156, 1);}
    .m_tab .curr{background-color: rgba(26, 188, 156, 1);color:#fff;}
    .m_tab .curr:hover{color: #fff;}
    .table>tbody>tr>td{vertical-align:middle;}
</style>

<div class="m_tab">
    <a href="/admin/users/{{$id}}"><span class="tb curr">用户详情</span></a>
    <a href="/admin/users/{{$id}}/edit"><span class="tb">编辑资料</span></a>
    <div class="btn-group pull-right" style="margin-right: 5px;">
        <a href="/admin/users" class="btn btn-sm btn-default" title="列表"><i class="fa fa-list"></i>
            <span class="hidden-xs">&nbsp;返回列表</span>
        </a>
    </div>
</div>
<div class="box box-solid">
    <div class="box-body no-padding">
        <table class="table show_tb">
            <tbody>
            <tr>
                <td rowspan="6" class="img_td">
                    <div class="img_div">
                        <img src="{{'/uploads/'.$avatar}}">
                        <br>
                        <span>{{$username}}</span>
                        <span class="department">

                        @if($department)
                            @foreach($department as $key=>$val)
                                {{$val['name']}}&nbsp;
                            @endforeach
                        @else
                            村民
                        @endif
                        </span>
                    </div>
                </td>
            </tr>
            <tr>
                <td rowspan="6" class="img_td">
                    {!! QrCode::size(200)->generate(base64_encode($id)) !!}
                </td>
            </tr>
            <tr>
                <td>
                    <span>用户ID</span>
                </td>
                <td>
                    {{$id}}
                </td>
                <td>
                    家庭人数
                </td>
                <td>
                    {{count($family_users)}}
                </td>
            </tr>
            <tr>
                <td>
                    姓名
                </td>
                <td>
                    {{$username}}
                </td>
                <td>
                    户主
                </td>
                <td>
                    @if($householder)
                        {{$householder['username']}}
                    @endif
                </td>
            </tr>
            <tr>
                <td>
                    生日
                </td>
                <td>
                    {{$birthday}}
                </td>
                <td>
                    手机号
                </td>
                <td>
                    {{$mobile}}
                </td>
            </tr>
            <tr>
                <td>
                    城市
                </td>
                <td>
                    {{$mobile}}
                </td>
                <td>
                    性别
                </td>
                <td>
                    {{$gender}}
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">家庭信息</h3>
        <div class="box-tools pull-right">
            <div class="btn-group pull-right" style="margin-right: 10px">
                @if(!$family['family_id'])
                <a href="{{'/admin/family/create'}}" class="btn btn-sm btn-default" title="创建家庭">
                    <span class="hidden-xs">创建家庭</span>
                </a>
                @endif
                <a href="/admin/family/{{$family['family_id']}}/edit" class="btn btn-sm btn-default" title="添加成员">
                    <span class="hidden-xs">成员管理</span>
                </a>
            </div>
        </div>
    </div>
    <div class="box-body" style="display: block;">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>姓名</th>
                <th>联系方式</th>
                <th>地址</th>
                <th>与户主关系</th>
                <th>添加时间</th>
            </tr>
            </thead>

            <tbody>
            @foreach($family_users as $key=>$val)
                <tr>
                    <td>
                        <span>{{$val['username']}}</span>
                    </td>
                    <td>
                        <span>{{$val['mobile']}}</span>
                    </td>
                    <td>
                        @if($family['family'])
                            <span>{{$family['family']['address']}}</span>
                        @endif
                    </td>
                    <td>
                            <span>
                                @if($val['is_householder'] && $val['relation_id'] == '0')
                                    户主
                                @else
                                    {{$val['relation_name']}}
                                @endif
                            </span>
                    </td>
                    <td>
                        <span>{{$val['created_at']}}</span>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
</div>






